package org.hiberlyzer.impl;

import org.hiberlyzer.DataColumn;
import org.hibernate.metadata.CollectionMetadata;
import org.hibernate.persister.collection.AbstractCollectionPersister;

public class CollectionDataColumn implements DataColumn
{
	private String name;
	private Class collectionClass;
	private Class elementClass;
	private CollectionMetadata metadata;
	
	CollectionDataColumn(String name, Class collectionClass, Class elementClass, CollectionMetadata metadata)
	{
		this.name = name;
		this.collectionClass = collectionClass;
		this.elementClass = elementClass;
		this.metadata = metadata;
	}

	public String getName()
	{
		return name;
	}

	public boolean hasMetadata()
	{
		return true;
	}

	public String formatValue(Object value)
	{
		if(value == null)
		{
			return "NULL";
		}
		return ((AbstractCollectionPersister) metadata).getCollectionType().toString();
	}
}
